from datetime import datetime, timedelta


def get_month_start_end(year, month):
    # 月份开始
    start_date = datetime(year, month, 1)
    # 月份结束
    end_date = (datetime(year, month + 1, 1) - timedelta(days=1)).replace(hour=23, minute=59, second=59)
    return start_date.strftime('%Y-%m-%d %H:%M:%S'), end_date.strftime('%Y-%m-%d %H:%M:%S')


def get_start_end_from_time(specified_time):
    # 将指定时间转换为datetime对象
    specified_datetime = datetime.strptime(specified_time, '%Y-%m-%d %H:%M:%S')

    # 获取年份和月份
    year = specified_datetime.year
    month = specified_datetime.month
    return get_month_start_end(year, month)

